<template>
  <div class="search-history">
  <van-cell title="历史">
    <div v-if="isshow">
      <span @click="$emit('del')">全部删除</span>
      &nbsp;&nbsp;
     <span @click="isshow = false">完成</span>
    </div>
    <van-icon v-else name="delete-o" @click="isshow = true" />
  </van-cell>
  <van-cell :title="item" v-for="(item,index) in historylist" :key="index" @click="delhist(item,index)">
    <van-icon v-show="isshow" name="close" />
  </van-cell>
  </div>
</template>

<script>
export default {
  data(){
    return{
  isshow:false
    }
  },
props:{
  historylist:{
    type:Array,
    required:true,
  }
},
methods:{
  delhist(item,index){
  if(this.isshow){
    this.historylist.splice(index,1)
  }else{
   this.$emit('search',item)
  }
  }
}
}
</script>

<style>

</style>